import java.net.ServerSocket;
import java.net.Socket;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
public class Server {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(9876);
            Socket socket = serverSocket.accept();
            InputStream is = socket.getInputStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader in = new BufferedReader(isr);
            OutputStream os = socket.getOutputStream();
            PrintWriter out = new PrintWriter(os,true);
            String line;
            String line2;
            while((line = in.readLine()) != null) {
                System.out.println("server got: " + line);
                line2 = StringToArithmetic.stringToArithmetic(line);
                out.println(line2);
            }
            out.close();
            in.close();
            socket.close();
            serverSocket.close();
        } catch (IOException e) {
            System.out.println(e);
            System.exit(1);
        }
    }
}